<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<div id="app">
    <template>
        <iframe :src="apiUrl" style="width: 100%;height: 100vh"></iframe>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    new Vue({
        el: '#app',
        data() {
			return {
                tableData: [],
                button: {
                    export: false
                },
                apiUrl:"",
                queryForm: {
                    swaggerUrl: '',
                    url: '',
                    title: ''
                }
			}
        },
        created() {
            this.handleQuery();
			let sysButtons = JSON.parse(localStorage.getItem("mars-sysButtons"));
			this.button.export = sysButtons.indexOf("tool/api/export") > -1;
        },
        methods: {
            formatTitle: function(row, column, cellValue, index) {
                return row.tags + "-" + row.title;
            },
            handleQuery() {
                requests.get('/tool/api/getApiUrl/').then(res=>{
                    console.log(res)
                    this.apiUrl=res.data
                })
            },
            handleExport() {
                let selectedRows = this.$refs.multipleTable.selection;
                let urlList = selectedRows.map(item => {
                    return item.url;
                });
                if (urlList.length <= 0) {
                    parent.layer.msg('请选择数据');
                } else {
                    let queryParam = {
                        swaggerUrl:this.queryForm.swaggerUrl,
                        url:this.queryForm.url,
                        title:this.queryForm.title,
                        urlList:urlList
                    };
                    exports('/tool/api/export', queryParam);
                }
            }
        }
    });
</script>
</html>
